﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace WpfApplication1.Converter
{
    class BoolColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType == typeof(Brush))
            {
                bool var = (bool) value;
                Color color;
                try
                {
                    if (var == true)
                        color = (Color)ColorConverter.ConvertFromString("#555555");
                    else
                        color = (Color)ColorConverter.ConvertFromString("#3E3E3E");
                    return new SolidColorBrush(color);
                }
                catch
                {
                    return DependencyProperty.UnsetValue;
                }
            }
            else return DependencyProperty.UnsetValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }   
    }
}
